<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\BaseController;
use App\Models\Config;
use App\Models\Share;
use App\Models\VoiceTranslate;
use Illuminate\Http\Request;

class VoiceTranslateController extends BaseController
{

    protected $model = VoiceTranslate::class;
    /**
     * 列表
     * @param Request $request
     * @return mixed
     */
    public function index(Request $request) {
        $input = $request->input();
        $voice_translate_pv = Config::where('key', 'voice_translate_pv')->value('value');
        $voice_translate_introduce_pv = Config::where('key', 'voice_translate_introduce_pv')->value('value');
        $share_count = Share::where('entity_type', Share::TYPE_VOICE_TRANSLATE)->count();
        $search = ['start_at' => '', 'end_at' => '', 'title' => '', 'user_id' => 0];
        $list = VoiceTranslate::apply($search, $input)->withCertain('user', ['nickname', 'avatar_url'])
            ->orderBy("id", "desc")
            ->paginate(per_page());
        return $this->paginate($list, compact('share_count', 'voice_translate_introduce_pv', 'voice_translate_pv'));
    }

}

